/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  // const valid_map = ['admin', 'editor']
  // return valid_map.indexOf(str.trim()) >= 0
  return true
}

export const VALIDATE_COUNT = (rule, value, callback) => {
  if (!value) {
    return callback(new Error('数量不能为空'))
  }
  var regex = /^[0-9]+.?[0-9]*$/
  if (!regex.test(value)) {
    callback(new Error('请输入正的数量'))
  } else {
    callback()
  }
}
